/*
 *  Copyright (c) 2020-2021 Guo Limin
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.github.x19990416.mxpaas.module.auth.shiro.token;

import com.github.x19990416.mxpaas.module.auth.util.JwtUtil;
import org.apache.shiro.authc.AuthenticationToken;

public class JwtToken implements AuthenticationToken {

  private static final long serialVersionUID = 1L;

  // 加密后的 JWT token串
  private String token;

  private String userName;

  public JwtToken(String token) {
    this.token = token;
    this.userName = JwtUtil.getClaim(token);
  }

  @Override
  public Object getPrincipal() {
    return this.userName;
  }

  @Override
  public Object getCredentials() {
    return token;
  }
}
